﻿@using Board.Models
@{
    ViewBag.Title = "UserList";
}

<h2>User List</h2>

@if (ViewBag.Users != null)
{
    List<WebUser> users = (List<WebUser>)ViewBag.Users;
    <text>
        <table width="100%">
            <thead>
                <tr>
                    <th>Username</th>
                    <th>Full Name</th>
                    <th>Register Date</th>
                    <th>Roles</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @foreach (WebUser user in users)
                {
                    <text>
                        <tr>
                            <td>@user.Username</td>
                            <td>@user.FullName</td>
                            <td>@user.CreationDate.ToString("MMM dd, yyyy")</td>
                            <td>@string.Join(" ", user.Roles.Select(r=>r.RoleName))</td>
                            <td>@Html.ActionLink("Detail", "UserDetail", new{userId=user.UserId}) | @Html.ActionLink("Modify", "UserModify", new{userId=user.UserId})</td>
                        </tr>
                    </text>
                }
            </tbody>
        </table>
        <p>
            @Html.ActionLink("Create a New User", "NewUser") 
        </p>
    </text>
}
